﻿<!--#include file="Conn.asp"-->
<!--#include file="Upload_Class.asp"-->
<%
dim subject
dim upload
dim fileid
set upload = new AnUpLoad
upload.Exe = "doc|docx|xls|xlsx|ppt|pps|pptx|pdf|txt|chm|rar|zip|7z|gz"
upload.MaxSize = 20 * 1024 * 1024 '20M
upload.Charset="gb2312"
upload.GetData()



if upload.ErrorID>0 then 
	'response.Write upload.Descreiption
	if upload.ErrorID=3 then
	Response.Write("<Script>alert('只允许上传类型为doc|docx|xls|xlsx|ppt|pps|pptx|pdf|txt|chm|rar|zip|7z|gz的文件！');history.go(-1);</Script>")
	end if
else
    set file = upload.files("file")
	dim file,savpath
	savepath = "upload"
	if not(file is nothing) then
		if file.saveToFile(savepath,0,true) then
			'response.Write ("文件'" & file.LocalName & "'上传成功，保存位置'" & server.MapPath(savepath & "/" & file.filename) & "',文件大小" & file.size & "字节<br/>"&"!")
            fileid=Left(file.filename,18)
            filelocation=file.filename
            filename=upload.forms("filename")
            filedesc=upload.forms("message")
            uploaduser=session("username")
            uploadtime=date()
            viewtimes=0
            filestate=0
            filestar=0
            sql="INSERT INTO resource VALUES ('"&fileid&"','"&filename&"','"&uploaduser&"','"&uploadtime&"',0,0,0,'wj','"&filedesc&"','"&filelocation&"','all')"
            
		else
			'response.Write file.Exception
		end if
		Conn.execute sql
		
	    session("name1")=file.LocalName
	
	set file = nothing
	end if
	href="view.asp?fileid="&fileid&""
	Response.Redirect(href)
end if
set upload = nothing
Conn.close
set Conn=nothing
%>